/**
 * @생성일 : 2011. 9. 14.
 * @package : com.luffy.jsonp.view
 * 
 *
 */
package com.luffy.view;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * <pre>
 * 역할적기.
 * </pre>
 * @작성자 : Administrator
 * @작성일 : 2011. 9. 14.
 * @package : com.luffy.jsonp.view
 *
 */
public class JsonpView extends JsonView {
	public static final String DEFAULT_CONTENT_TYPE = "javascript/jsonp";
	
	
	public JsonpView(){
		setContentType(DEFAULT_CONTENT_TYPE);	
	}

	@Override
	protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request,
		HttpServletResponse response) throws Exception {
		
		String callback = request.getParameter("callback");
		if(callback == null){
			callback = "callback";			
		}
		
		String resultStr = callback +"(" + jsonXstream.toXML(model) + ");"; 

		writeToResponse(response,resultStr);
	}
}